package com.ewili.x.special.service.data.impl;

import com.ewili.framework.utils.ExceptionUtils;
import com.ewili.x.special.dao.inter.StockDao;
import com.ewili.x.special.entity.Stock;
import com.ewili.x.special.service.data.inter.FinanceReportService;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Service
public class FinanceReportServiceImpl implements FinanceReportService {

    @Autowired
    private StockDao stockDao;

    @Override
    public List<String> createUrls() {
        List<Stock> stocks = stockDao.findAll();

        List<String> urls = new ArrayList<>();
        for (Stock stock : stocks) {
            String url = "http://data.eastmoney.com/notices/getdata.ashx?StockCode=" + stock.getCode() + "&CodeType=1&PageIndex=1&PageSize=100000&jsObj=nKHleEvE&SecNodeType=1&FirstNodeType=1&rt=51391497";
            try {
                Document document = Jsoup.connect(url).get();
            } catch (IOException e) {
                ExceptionUtils.propagate(e);
            }
        }

        return null;
    }
}
